package cn.com.twoke.app.pin_dou_dou;

import cn.com.twoke.app.pin_dou_dou.color.ColorDifferenceAnalyzer;

import java.awt.Color;

public class ColorDifferenceExample {
    public static void main(String[] args) {
        // 测试用例
        Color[] testColors = {
            Color.RED, new Color(255, 0, 1),     // 非常相似
            Color.RED, Color.GREEN,              // 完全不同
            Color.BLACK, Color.WHITE,            // 极端对比
            new Color(100, 100, 100), new Color(105, 105, 105), // 灰度相似
            new Color(255, 200, 100), new Color(250, 205, 110)  // 相似色调
        };
        
        System.out.println("=== 色差计算测试 ===\n");
        
        for (int i = 0; i < testColors.length; i += 2) {
            ColorDifferenceAnalyzer.compareAllMethods(testColors[i], testColors[i+1]);
        }
        
        // 特定测试
        System.out.println("=== 特定颜色比较 ===");
        Color baseColor = new Color(128, 128, 128); // 中性灰
        
        Color[] variations = {
            new Color(130, 128, 128), // 轻微红色偏移
            new Color(128, 130, 128), // 轻微绿色偏移
            new Color(128, 128, 130), // 轻微蓝色偏移
            new Color(140, 128, 128), // 明显红色偏移
        };
        
        for (Color variation : variations) {
            double deltaE = ColorDifferenceAnalyzer.CIE2000.deltaE(baseColor, variation);
            String perception = ColorDifferenceAnalyzer.getPerceptionLevel(deltaE);
            System.out.printf("与基准灰的 ΔE*00: %.3f - %s%n", deltaE, perception);
        }
        
        // 实用性测试
        System.out.println("\n=== 实用性测试 ===");
        Color targetColor = new Color(255, 100, 50); // 目标颜色
        Color[] candidateColors = {
            new Color(255, 105, 55),
            new Color(250, 95, 45),
            new Color(255, 120, 60),
            new Color(240, 80, 40)
        };
        
        System.out.println("寻找与目标颜色最相似的候选颜色:");
        for (int i = 0; i < candidateColors.length; i++) {
            double deltaE = ColorDifferenceAnalyzer.CIE2000.deltaE(targetColor, candidateColors[i]);
            System.out.printf("候选%d: ΔE*00 = %.3f (%s)%n", 
                i+1, deltaE, ColorDifferenceAnalyzer.getPerceptionLevel(deltaE));
        }
    }
}